
vapp = new Vue(
		{
			el : '#app',
			data : {
				loading: false,	
				oldPassword : '',
				newPassword	: '',		 
				newPasswordr	: '',		 
		       
			},
			
			created : function() {

				tools.loadDiv();
				

			},
			mounted : function() {
				   var that = this; 
					
				   //this.initData();

			},
			
			
			watch : {


			},
			methods : {	
				checkoldpassword: function(oldpasswd) {
					if (!oldpasswd.isEmpty()) {	
						
						 console.log(this.curTreeLevel);
							var postdata = {
								"oldPassWord" : oldpasswd.MD5(),
								
							};
//							 console.log(JSON.stringify(postdata));							
							var v = tools.ajaxRequest("../../pub/userInfo/checkoldpasswd",postdata);
							// console.log(JSON.stringify(v));	
							if (v.respCode != "0") {
								return false;
									
							}
							return true;
					}
					
				},
				checknewpassword: function (passwd) {
				
					var reg = /^.*(?=.{6,})(?=.*\d)(?=.*[a-z]).*$/;  //最少6位，包括至少1个大写字母，1个小写字母，1个数字
					if(!reg.test(passwd)){						
						return false;						
					}
					return true;		
				},
				
				checkrpassword: function(passwd) {
					var newPwd = $.trim(this.newPassword);
					if(newPwd!=passwd){
						return true;
					}
					return false;
					
				},
				save:function(){
					var that=this;
					if(!this.checkoldpassword($.trim(this.oldPassword)))
					{
						this.showError("原密码错误");
						return false;
					}
					
				
					if(!this.checknewpassword($.trim(this.newPassword)))
					{
						this.showError("最少6位，包括至少1个小写字母，1个数字");
						return false;
					}
					
					if(this.checkrpassword($.trim(this.newPasswordr)))
					{
						this.showError("确认密码与新密码不一致");
						return false;
					}
					
					var postdata = {
							"newPassWord" : $.trim(this.newPassword).MD5(),				

						};
		        	
		    		tools
					.ajaxRequestAsync(
							"../../pub/userInfo/userInfoPwdSave",
							postdata,
							function(v) {

								if (v.respCode == "0") {
								
									 that.$message({
								        	showClose: true,
								            type: 'success',
								            message: '密码修改成功!'
								          });								
								} else {
									 that.$message({
								        	showClose: true,
								        	 type: 'info',
								            message: '密码修改失败!'
								          });						
								}
							});
					
					
					
				},
		        showError: function(info){
		            var i = (info==undefined?"加载数据错误":info);
		            this.$alert(i, '系统错误', {
		                 confirmButtonText: '确定'
		            }); 
		        },
				
			}
			

		});
